#ifndef _MVDATA_BLOCK_H_
#define _MVDATA_BLOCK_H_

#include "MVDataMBCommon.h"
#include "MVDataDefines.h"

class CMVData;
class CMVDataMB;

///@brief 定义Block的通用方法和行为，一个block在实际上可以是MB、SubMB和SubSubMB，此类型仅在外部使用
class CMVDataBlock : public CMVDataMBCommon
{

	//TODO: remove friends
	friend class CMVDataMB;
	friend class CMVDataSubMB;
	friend class CMVDataSubSubMB;

//============================== 一般方法 ====================================
public:
	///@brief 用于创建不同类型的Block对象，不能直接创建 CMVDataBlock 类型，只能创建其派生类型
	static CMVDataBlock * CreateBlock( TYPE_BLOCK block_type = TYPE_BLOCK_P );

protected:
	CMVDataBlock( TYPE_BLOCK block_type );
	CMVDataBlock( const CMVDataBlock& block );

public:
	CMVDataBlock& operator =( const CMVDataBlock& block );

//============================== 属性方法 ====================================
public:
	///@brief 取得第一层次的位置
	LOC_BLOCK GetFirstLayerLoc() const;
	///@brief 设置第一层次的位置
	int SetFirstLayerLoc( LOC_BLOCK first_layer_loc );

	///@brief 取得第二层次的位置
	LOC_BLOCK GetSecondLayerLoc() const;
	///@brief 设置第二层次的位置
	int SetSecondLayerLoc( LOC_BLOCK second_layer_loc );

	///@brief 同时设置两个层次位置
	int SetAllLayerLoc( LOC_BLOCK first_layer_loc, LOC_BLOCK second_layer_loc );

	///@brief 取得当前Block的类型
	TYPE_BLOCK GetBlockType() const;

	///@brief 取得当前Block所属于的MB指针
	const CMVDataMB * GetMB() const;
	///@brief 设置当前Block所属于的MB指针
	int SetMB( const CMVDataMB * mb );


	///@brief 这个Block是否合法
	virtual bool IsValid() const;

	///@brief 从内部类型中拷贝数据
	int CopyDataFrom( const CMVDataMBCommon * pCommon );

private:
	SHAPE_BLOCK GetShape() const;
	
//============================== 类成员 ====================================
private:
	LOC_BLOCK m_eFirstLayerLoc;
	LOC_BLOCK m_eSecondLayerLoc;

	const CMVDataMB * m_pMB;

	TYPE_BLOCK m_eBlockType;

};




#endif // _MVDATA_BLOCK_H_